#pragma once
#include "HashTable.h"
namespace my_stl
{
    template <class K, class V, class hashfunc = defultfunc<K>>
    class unordered_map
    {
        struct mapkeyof
        {
            const K &operator()(const pair<K, V> &kv)
            {
                return kv.first;
            }
        };

    public:
        typedef typename HashTable<K, pair<K, V>, hashfunc, mapkeyof>::iterator iterator;
        pair<iterator, bool> insert(const pair<K, V> &kv)
        {
            return map_table->insert(kv);
        }
        bool erase(const K &key)
        {
            return map_table->erase();
        }
        iterator begin()
        {
            return map_table->begin();
        }
        iterator end()
        {
            return map_table->end();
        }
        iterator find(const K &key)
        {
            return map_table->find(key);
        }
        V &operator[](const K &key)
        {
            pair<iterator, bool> ret = insert(make_pair(key, V()));
            return ret.first->second;
        }

    private:
        HashTable<K, pair<K, V>, hashfunc, mapkeyof> *map_table;
    };
}